{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import cPickle\n",
    "import numpy as np\n",
    "import os\n",
    "\n",
    "CIFAR_DIR = \"./../../cifar-10-batches-py\"\n",
    "print os.listdir(CIFAR_DIR)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open(os.path.join(CIFAR_DIR, \"data_batch_1\"), 'rb') as f:\n",
    "    data = cPickle.load(f)\n",
    "    print type(data)\n",
    "    print data.keys()\n",
    "    print type(data['data'])\n",
    "    print type(data['labels'])\n",
    "    print type(data['batch_label'])\n",
    "    print type(data['filenames'])\n",
    "    print data['data'].shape\n",
    "    print data['data'][0:2]\n",
    "    print data['labels'][0:2]\n",
    "    print data['batch_label']\n",
    "    print data['filenames'][0:2]\n",
    "\n",
    "# 32 * 32 = 1024 * 3 = 3072\n",
    "# RR-GG-BB = 3072\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "image_arr = data['data'][100]\n",
    "image_arr = image_arr.reshape((3, 32, 32)) # 32 32 3\n",
    "image_arr = image_arr.transpose((1, 2, 0))\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "from matplotlib.pyplot import imshow\n",
    "%matplotlib inline\n",
    "\n",
    "imshow(image_arr)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
